/*
package com.itheima.day11;

import java.util.ArrayList;

class User {
    private String name;
    private int age;
    private String sex;

    public User() {
    }

    public User(String name, int age, String sex) {
        this.name = name;
        this.age = age;
        this.sex = sex;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    public String getSex() {
        return sex;
    }

    public void setSex(String sex) {
        this.sex = sex;
    }
}
public class Test3 {
    public static void main(String[] args) {
        //定义5个User对象,并存入ArrayList集合
        User user1 = new User("张三",18,"男");
        User user2 = new User("李四",14,"男");
        User user3 = new User("张雪",19,"女");
        User user4 = new User("赵六",20,"男");
        User user5 = new User("张日",8,"男");
        ArrayList<User> list = new ArrayList<>();
        list.add(user1);
        list.add(user2);
        list.add(user3);
        list.add(user4);
        list.add(user5);
        //调用getUser方法,筛选出符合条件的数据

    }
    */
/*
        功能:将传过来的集合中年龄大于18并且性别为"男"的User对象筛选出来,存入新的集合,并将新集合返回
     *//*

    public static ArrayList<User> getUser(ArrayList<User> users){
        //1.定义一个新容器,用来存放筛选后符合条件的User对象
        ArrayList<User> newList = new ArrayList<>();

        //2.遍历老容器,筛选出年龄大于等于18并且性别为"男"的User对象
        for(int i = 0; i < users.size();i++){
            //2.1拿到老容器中每一个User对象
            User user = users.get(i);
            //2.2判断当前索引位置的User对象是否符合条件
            if(user.getAge() >= 18 && "男".equals(user.getSex())){
                //2.3将符合条件的User对象存入新容器
                newList.add(user);
            }
        }
    }
}
*/
